<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Encrypts data</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.openssl-digest.html">openssl_digest</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.openssl-error-string.html">openssl_error_string</a></div>
 <div class="up"><a href="ref.openssl.html">OpenSSL 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.openssl-encrypt" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">openssl_encrypt</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.3.0)</p><p class="refpurpose"><span class="refname">openssl_encrypt</span> &mdash; <span class="dc-title">Encrypts data</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.openssl-encrypt-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">string</span> <span class="methodname"><strong>openssl_encrypt</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$data</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$method</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$password</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$options</code><span class="initializer"> = 0</span></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$iv</code><span class="initializer"> = &quot;&quot;</span></span>
  ]] )</div>

  <p class="para rdfs-comment">
   Encrypts given data with given method and key, returns a raw
   or base64 encoded string
  </p>

  <div class="warning"><strong class="warning">Warning</strong><p class="simpara">本函数还未编写文档，仅有参数列表。</p></div>

 </div>


 <div class="refsect1 parameters" id="refsect1-function.openssl-encrypt-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">data</code></em></dt>

     <dd>

      <p class="para">
       The data.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">method</code></em></dt>

     <dd>

      <p class="para">
       The cipher method.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">password</code></em></dt>

     <dd>

      <p class="para">
       The password.
      </p>
     </dd>

    
    
      <dt>
<em><code class="parameter">options</code></em></dt>

      <dd>

        <p class="para">
          <em><code class="parameter">options</code></em> can be one of
          <strong><code>OPENSSL_RAW_DATA</code></strong>,
          <strong><code>OPENSSL_ZERO_PADDING</code></strong>.
        </p>
      </dd>

    
    
     <dt>
<em><code class="parameter">iv</code></em></dt>

     <dd>

      <p class="para">
       A non-NULL Initialization Vector.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.openssl-encrypt-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns the encrypted string on success 或者在失败时返回 <strong><code>FALSE</code></strong>.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-function.openssl-encrypt-errors">
  <h3 class="title">错误／异常</h3>
  <p class="para">
   Emits an <strong><code>E_WARNING</code></strong> level error if an unknown cipher
   algorithm is passed in via the <em><code class="parameter">method</code></em> parameter.
  </p>
  <p class="para">
   Emits an <strong><code>E_WARNING</code></strong> level error if an empty value is passed
   in via the <em><code class="parameter">iv</code></em> parameter.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.openssl-encrypt-changelog">
  <h3 class="title">更新日志</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>版本</th>
      <th>说明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>5.3.3</td>
      <td>
       The <em><code class="parameter">iv</code></em> parameter was added.
      </td>
     </tr>

     <tr>
      <td>5.4.0</td>
      <td>
       The <em><code class="parameter">raw_output</code></em> was changed to <em><code class="parameter">options</code></em>.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 seealso" id="refsect1-function.openssl-encrypt-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.openssl-decrypt.html" class="function" rel="rdfs-seeAlso">openssl_decrypt()</a> - Decrypts data</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.openssl-digest.html">openssl_digest</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.openssl-error-string.html">openssl_error_string</a></div>
 <div class="up"><a href="ref.openssl.html">OpenSSL 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
